package com.rzico.basics.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.rzico.basics.entity.Coupon;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 大转盘奖品
 * Created by macro on 2021/03/28.
 */
@Data
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PrizeVo {

    @ApiModelProperty("奖品名")
    private String prizeName;

    @ApiModelProperty("使用门槛")
    private Integer scope;

    @ApiModelProperty("有效期")
    private Date deadline;

    @ApiModelProperty("满减或折扣/金额")
    private BigDecimal amount;

    @ApiModelProperty(value = "使用条件(满额)")
    protected BigDecimal minimumPrice;

    @ApiModelProperty("奖品类型")
    private Integer prizeType;

    @ApiModelProperty(value = "优惠方式 {0:满减券,1:折扣券,3.兑换券}")
    private Integer type;

    @ApiModelProperty("附属ID：如类型为优惠券则该值保存优惠券ID")
    private String subId;

    public static PrizeVo format(Coupon coupon) {
        PrizeVo vo = new PrizeVo();
        vo.setPrizeName(coupon.getName());
        vo.setScope(coupon.getScope());
        vo.setDeadline(coupon.getEndDate());
        vo.setAmount(coupon.getAmount());
        vo.setMinimumPrice(coupon.getMinimumPrice());
        vo.setType(coupon.getType());
        vo.setPrizeType(1);
        vo.setSubId(String.valueOf(coupon.getId()));
        return vo;
    }

}
